{set:$seo_data=array();$site_config=new Config('site_config');$site_config=$site_config->getInfo();}
{set:$seo_data['title']="商品搜索_".$site_config['name']}
{set:seo::set($seo_data);}
{set:$defaultWhere = array('search' => $this->word , 'category_extend' => $this->cat_id )}
{set:$goodsObj = search_goods::find($defaultWhere);$resultData = $goodsObj->find();}

<div class="position"> <span>全部结果：</span> <a href="javascript:void(0)">{$this->word}</a> </div>
<div class="wrapper clearfix container_2">
	<div class="sidebar f_l">
		<div class="box_2 m_10">
			<div class="title">分类筛选</div>
			<div class="content">
				<dl class="w clearfix">
					{foreach:items=Api::run('getGoodsCategoryExtend',array('#word#',$this->word)) }
					{set:$tmpWord=urlencode($this->word);}
					<dd class='{if:IReq::get('cat') == $item['id']}current{/if}'><a href="{url:/site/search_list/word/$tmpWord/cat/$item[id]}">{$item['name']}({$item['num']})</a></dd>
					{/foreach}
				</dl>
			</div>
		</div>
		<div class="box m_10">
			{echo:Ad::show(8)}
		</div>
		<div class="box m_10">
			<div class="title">销售排行榜</div>
			<div class="content">
				<ul class="ranklist" id='ranklist'>
					{set:$whereCat = $this->cat_id ? " and ca.category_id in ($this->cat_id)" : ''}
				  	{foreach:items=Api::run('getGoodsListByWordSum',array('#word#',$this->word),array('#whereCat#',$whereCat)) }
				  	<li>
				  		<span>{echo:intval($key+1)}</span>
				  		<a href="{url:/site/products/id/$item[id]}"><img src="{url:/pic/thumb/img/$item[img]/w/60/h/60}" width="60" height="60" alt="{$item['name']}" /></a>
				  		<a title="{$item['name']}" class="p_name" href="{url:/site/products/id/$item[id]}">{$item['name']}</a><b>￥{$item['sell_price']}</b>
				  	</li>
				  	{/foreach}
				</ul>
			</div>
		</div>
	</div>
	<div class="search_list main f_r">
		<strong class="result">"<span class="red">{$this->word}</span>" 搜索结果</strong>
		<p class="t_l gray m_10">你是不是想找：
			{foreach:items=Api::run('getKeywordByWord',array('#word#',$this->word)) }
			{set:$tmpWord=urlencode($item['word']);}
			<a href="{url:/site/search_list/word/$tmpWord}" class='orange'>{$item['word']}</a>
			{/foreach}
		</p>

		<!--商品条件检索-->
		<div class="box m_10">
			<div class="cont">

				<!--品牌展示-->
				{set:$brandList = search_goods::$brandSearch}
				{if:$brandList}
				<dl class="sorting">
					<dt>品牌：</dt>
					<dd id='brand_dd'>
						<a class="nolimit current" href="{echo:search_goods::searchUrl('brand','')}">不限</a>
						{foreach:items = $brandList}
						<a href="{echo:search_goods::searchUrl('brand',$item['id'])}" id='brand_{$item['id']}'>{$item['name']}</a>
						{/foreach}
					</dd>
				</dl>
				{/if}
				<!--品牌展示-->

				<!--商品属性-->
				{foreach:items = search_goods::$attrSearch}
				<dl class="sorting">
					<dt>{$item['name']}：</dt>
					<dd id='attr_dd_{$item['id']}'>
						<a class="nolimit current" href="{echo:search_goods::searchUrl('attr['.$item["id"].']','')}">不限</a>
						{foreach:items=$item['value'] item=$attr}
						<a href="{echo:search_goods::searchUrl('attr['.$item["id"].']',$attr)}" id="attr_{$item['id']}_{echo:md5($attr)}">{$attr}</a>
						{/foreach}
					</dd>
				</dl>
				{/foreach}
				<!--商品属性-->

				<!--商品价格-->
				<dl class="sorting">
					<dt>价格：</dt>
					<dd id='price_dd'>
						<p class="f_r"><input type="text" class="mini" name="min_price" value="{echo:IFilter::act(IReq::get('min_price'),'url')}" onchange="checkPrice(this);"> 至 <input type="text" class="mini" name="max_price" onchange="checkPrice(this);" value="{echo:IFilter::act(IReq::get('max_price'),'url')}"> 元
						<label class="btn_gray_s"><input type="button" onclick="priceLink();" value="确定"></label></p>
						<a class="nolimit current" href="{echo:search_goods::searchUrl(array('min_price','max_price'),'')}">不限</a>
						{foreach:items=search_goods::$priceSearch}
						{set:$priceZone = explode('-',$item)}
						<a href="{echo:search_goods::searchUrl(array('min_price','max_price'),array($priceZone[0],$priceZone[1]))}" id="{$priceZone[0]}-{$priceZone[1]}">{$item}</a>
						{/foreach}
					</dd>
				</dl>
				<!--商品价格-->
			</div>
		</div>
		<!--商品条件检索-->

		<div class="display_title m_10">
			<span class="l"></span>
			<span class="r"></span>
			<span class="f_l">排序：</span>
			<ul>
				{foreach:items=search_goods::getOrderType()}
				{set:$next = search_goods::getOrderValue($key)}
				<li class="{echo:search_goods::isOrderCurrent($key) ? 'current':''}">
					<span class="l"></span><span class="r"></span>
					<a href="{echo:search_goods::searchUrl('order',$next)}">{$item}<span class="{echo:search_goods::isOrderDesc() ? 'desc':''}">&nbsp;</span></a>
				</li>
				{/foreach}
			</ul>
			<span class="f_l">显示方式：</span>
			<a class="show_b" href="{echo:search_goods::searchUrl('show_type','win')}" title='橱窗展示' alt='橱窗展示'><span class='{echo:search_goods::getListShow(IReq::get('show_type')) == 'win' ? 'current':''}'></span></a>
			<a class="show_s" href="{echo:search_goods::searchUrl('show_type','list')}" title='列表展示' alt='列表展示'><span class='{echo:search_goods::getListShow(IReq::get('show_type')) == 'list' ? 'current':''}'></span></a>
		</div>

		{if:$resultData}
		{set:$listSize = search_goods::getListSize(IFilter::act(IReq::get('show_type')))}
		<ul class="display_list clearfix m_10">
			{foreach:items=$resultData}
			<li class="clearfix {echo:search_goods::getListShow(IFilter::act(IReq::get('show_type')))}">
				<div class="pic">
					<a title="{$item['name']}" href="{url:/site/products/id/$item[id]}"><img src="{url:/pic/thumb/img/$item[img]/w/$listSize[width]/h/$listSize[height]}" width="{$listSize['width']}" height="{$listSize['height']}" alt="{$item['name']}" title="{$item['name']}" /></a>
				</div>
				<h3 class="title"><a title="{$item['name']}" class="p_name" href="{url:/site/products/id/$item[id]}">{echo:str_replace($this->word,'<b class="red">'.$this->word.'</b>',$item['name'])}</a><span>总销量：{$item['sale']}<a class="blue" href="{url:/site/comments_list/id/$item[id]}">( {$item['comments']}人评论 )</a></span><span class='grade'><i style='width:{echo:Common::gradeWidth($item['grade'],$item['comments'])}px'></i></span></h3>
				<div class="handle">
					<label class="btn_gray_m"><img src="{skin:images/front/ucenter/shopping.gif}" width="15" height="15" /><input type="button" value="加入购物车" onclick="joinCart_list({$item['id']});"></label>
					<label class="btn_gray_m"><img src="{skin:images/front/ucenter/favorites.gif}" width="15" height="14" /><input type="button" value="收藏" onclick="favorite_add_ajax('{url:/simple/favorite_add}','{$item['id']}',this);"></label>
				</div>
				<div class="price">￥{$item['sell_price']}<s>￥{$item['market_price']}</s></div>
			</li>
			{/foreach}
		</ul>
		{$goodsObj->getPageBar()}
		{else:}
		<p class="display_list mt_10" style='margin-top:50px;margin-bottom:50px'>
			<strong class="gray f14">对不起，没有找到相关商品</strong>
		</p>
		{/if}
	</div>
</div>

<script type='text/javascript'>
//价格跳转
function priceLink()
{
	var minVal = $('[name="min_price"]').val();
	var maxVal = $('[name="max_price"]').val();
	if(isNaN(minVal) || isNaN(maxVal))
	{
		alert('价格填写不正确');
		return '';
	}
	var urlVal = "{echo:IFilter::act(preg_replace('|&min_price=\w*&max_price=\w*|','',search_goods::searchUrl(array('min_price','max_price'),'')),'text')}";
	window.location.href=urlVal+'&min_price='+minVal+'&max_price='+maxVal;
}

//价格检查
function checkPrice(obj)
{
	if(isNaN(obj.value))
	{
		obj.value = '';
	}
}

//筛选条件按钮高亮
jQuery(function(){
	{set:
		$brand = IFilter::act(IReq::get('brand'),'int');
	}

	{if:$brand}
	$('#brand_dd>a').removeClass('current');
	$('#brand_{$brand}').addClass('current');
	{/if}

	{set:$tempArray = IFilter::act(IReq::get('attr'),'url')}
	{if:$tempArray}
		{set:$json = JSON::encode(array_map('md5',$tempArray))}
		var attrArray = {$json};
		for(val in attrArray)
		{
			if(attrArray[val])
			{
				$('#attr_dd_'+val+'>a').removeClass('current');
				document.getElementById('attr_'+val+'_'+attrArray[val]).className = 'current';
			}
		}
	{/if}

	{if:IReq::get('min_price') != ''}
	$('#price_dd>a').removeClass('current');
	$('#{echo:IReq::get('min_price')}-{echo:IReq::get('max_price')}').addClass('current');
	{/if}
});
</script>